package com.itic.appbase.applications.solr.impl;

import java.lang.reflect.ParameterizedType;
import java.util.List;

import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.itic.appbase.applications.solr.ISolrDao;
import com.itic.appbase.applications.solr.modal.Person;


@Repository
public class SolrDao<T> implements ISolrDao<T> {
	@Autowired  
    private HttpSolrServer httpSolrServer;
	
	private Class<T> entityClass;
	
	private Class<T> getClazz(){  
	    if (entityClass==null) {  
	    	entityClass=(Class<T>)(((ParameterizedType)this.getClass().getGenericSuperclass()).getActualTypeArguments()[0]);  
	    }
	    return entityClass;  
	} 
	 
	/*@Override
	public List<T> get(String id) throws SolrServerException {
		SolrQuery query = new SolrQuery();  
        query.setQuery("id:" + id);  
          
        //查询并返回结果  
        QueryResponse queryResponse = this.httpSolrServer.query(query); 
        SolrDocumentList list = queryResponse.getResults();
        for(SolrDocument doc : list)
        	
        	System.out.println(doc.get("title"));
        return  (List<T>) queryResponse.getBeans(Person.class);  
	}*/
	
	
	
	

}
